﻿using Furion.DatabaseAccessor;
using System;
using System.ComponentModel.DataAnnotations;
using YFurion.Locators;

namespace YFurion.Entities
{
    [Serializable]
    public abstract class CEntity : CEntityOfTKey<long>, IYEntity, ICreationAudited
    {
        [Key]
        public override long Id { get; set; }
    }

    [Serializable]
    public abstract class CEntity<TDbContextLocator1, TDbContextLocator2> :
        CEntityOfTKey<long, TDbContextLocator1, TDbContextLocator2>,
        IYEntity<TDbContextLocator1, TDbContextLocator2>,
        ICreationAudited
        where TDbContextLocator1 : class, IDbContextLocator
        where TDbContextLocator2 : class, IDbContextLocator
    {
        [Key]
        public override long Id { get; set; }
    }

    [Serializable]
    public abstract class CEntityOfTKey<TKey> : CEntityOfTKey<TKey, MasterDbContextLocator, SlaveDbContextLocator>, IYEntityOfTKey<TKey>, ICreationAudited<TKey>
    {
    }

    [Serializable]
    public abstract class CEntityOfTKey<TKey, TDbContextLocator1, TDbContextLocator2> : CEntityBase<TKey>,
        IYEntityOfTKey<TKey, TDbContextLocator1, TDbContextLocator2>,
        ICreationAudited<TKey>
        where TDbContextLocator1 : class, IDbContextLocator
        where TDbContextLocator2 : class, IDbContextLocator
    {
    }

    [Serializable]
    public abstract class CEntityBase<TKey> : YEntityBase<TKey>,
        ICreationAudited<TKey>
    {
        public virtual TKey CreatorUserId { get; set; }

        public virtual DateTime CreationTime { get; set; }
    }
}
